package com.cash.loan.modular.cash.controller;

import com.cash.loan.common.result.ServerResponse;
import com.cash.loan.modular.cash.service.VersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Administrator
 * @Date 2018-10-09 8:59
 */
@RestController
@RequestMapping(value = "/version")
@Api(description = "版本接口")
public class VersionController {

    @Autowired
    private VersionService versionService;

    @ApiOperation("版本检测")
    @PostMapping(value = "/check")
    public ServerResponse checkVersion(@RequestParam(value = "versionNum") String versionNum) {
        if(StringUtils.isBlank(versionNum)) {
            return ServerResponse.getErrorMessage("请输入正确的版本号");
        }
        Map<String,Object> result = versionService.check(versionNum);
        return ServerResponse.getSuccess("success",result);
    }
}
